for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
const stringifyProperty: SymbolConstructor["toPrimitive"] | "valueOf" | "toString" = Symbol.toPrimitive
const {
defineProperty: $defineProperty
} = Object
export {
stringifyClassNamed, emptize
}
function stringifyClassNamed<T extends {className: string}>(source: T) :T {
if (!source.hasOwnProperty(stringifyProperty))
$defineProperty(source, stringifyProperty, {value: classNamedToString})
return source
function classNamedToString(this: {className: string}) {
return this.className
function emptize(source: undefined|Record<string, any>) {
if (
source
&& !source.hasOwnProperty(stringifyProperty)
)
$defineProperty(source, stringifyProperty, {value: emptyLambda})
function emptyLambda() {
return "" as const